package cn.cloud.butler.webapi.controller;


import cn.cloud.butler.webapi.domain.ResponseEntity;
import cn.cloud.butler.webapi.domain.checkapk.CheckApkResponse;
import cn.cloud.butler.webapi.service.OperInformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

/**
 * author: tangyue
 * time: 2019-01-11
 * description: 机床加工信息接口
 */


@RestController
@EnableAutoConfiguration
@RequestMapping("/HncWeb")
public class OperInformationController {

    @Autowired
    OperInformationService operInformationService;


    /**
     * 按机床和页数查询加工信息
     * @param macsn 机床sn号
     * @param page 查询页数
     * @return ResponseEntity
     */
    @RequestMapping(method = RequestMethod.GET, value = "/SelectOperInfo.action")
    public ResponseEntity SelectOperInfo(String macsn, int page){
        ResponseEntity response = new ResponseEntity();
        try {
            List<Object> result = operInformationService.selectOperInfoByPageAndMacSn(macsn,page);
            if(result.size()<=0){
                response.setMsgDesc("查询失败");
                response.setMsgCode(1);
            }else{
                response.setMsgDesc("查询成功");
                response.setMsgCode(0);
                response.setData(result);
            }
        }catch (Exception e){
            response.setMsgDesc("查询报错" + e.toString());
            response.setMsgCode(-3);
        }finally {
            return response;
        }

    }
}
